Fixes #63 : UserDashboard with rich analytics#64
Merged
Kmadhav824 merged 4 commits intoshivamxverma:mainfrom May 4, 2026
Merged
Fixes #63 : UserDashboard with rich analytics#64Kmadhav824 merged 4 commits intoshivamxverma:mainfrom
Kmadhav824 merged 4 commits intoshivamxverma:mainfrom
Conversation
|
@Kmadhav824 is attempting to deploy a commit to the Shivam verma's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Pull request overview
Adds a new authenticated “User Dashboard” view that surfaces user-specific analytics (submission activity and solved counts) by introducing a new backend endpoint and wiring a new frontend route/UI.
Changes:
- Added
GET /submission/user/dashboardendpoint to return recent submissions plus solved/submission aggregates. - Implemented a new
UserDashboardReact page with stats cards, difficulty breakdown, and a recent submissions list. - Added a protected frontend route at
/dashboardand an API client helper to fetch dashboard stats.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| Frontend/src/views/dashboard/UserDashboard.jsx | New dashboard UI rendering user stats and recent submissions from the new API. |
| Frontend/src/App.jsx | Adds protected /dashboard route to render the new UserDashboard page. |
| Frontend/src/api/api.js | Adds getUserDashboardStats() API client wrapper. |
| backend/src/api/submission/submission-service.ts | Implements handleGetUserDashboardStats DB queries and response formatting. |
| backend/src/api/submission/submission-route.ts | Registers the new /user/dashboard submission route (JWT-protected). |
| backend/src/api/submission/submission-controller.ts | Adds controller handler to serve dashboard stats response. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function Counter({ target, duration = 1200 }) { | ||
| const [val, setVal] = useState(0); | ||
| useEffect(() => { | ||
| if (!target) return; |
Comment on lines
+170
to
+174
| const solved = stats?.solvedByDifficulty ?? { easy: 0, medium: 0, hard: 0 }; | ||
| const totalSolved = stats?.totalSolved ?? 0; | ||
| const acceptRate = stats?.totalSubmissions | ||
| ? Math.round((totalSolved / stats.totalSubmissions) * 100) | ||
| : 0; |
Comment on lines
+244
to
+263
| {[ | ||
| { label: "Easy", count: solved.easy, color: "bg-emerald-500", text: "text-emerald-400", total: 100 }, | ||
| { label: "Medium", count: solved.medium, color: "bg-amber-500", text: "text-amber-400", total: 100 }, | ||
| { label: "Hard", count: solved.hard, color: "bg-rose-500", text: "text-rose-400", total: 100 }, | ||
| ].map(({ label, count, color, text, total }) => ( | ||
| <div key={label} className="space-y-1"> | ||
| <div className="flex justify-between text-xs"> | ||
| <span className={`font-semibold ${text}`}>{label}</span> | ||
| <span className="text-slate-400 tabular-nums"> | ||
| {loading ? "—" : count} <span className="text-slate-600">/ {total}</span> | ||
| </span> | ||
| </div> | ||
| <div className="h-2 rounded-full bg-white/5 overflow-hidden"> | ||
| <div | ||
| className={`h-full rounded-full ${color} transition-all duration-1000`} | ||
| style={{ width: loading ? "0%" : `${Math.min((count / total) * 100, 100)}%` }} | ||
| /> | ||
| </div> | ||
| </div> | ||
| ))} |
| import { db } from '../../loaders/postgres'; | ||
| import redis from '../../loaders/redis'; | ||
| import { eq, and, desc } from 'drizzle-orm'; | ||
| import { eq, and, desc, count, sql } from 'drizzle-orm'; |
Comment on lines
+226
to
+251
| // Accepted problems (distinct problems with ACCEPTED verdict) | ||
| const acceptedProblems = await db | ||
| .selectDistinct({ problemId: submission.problemId }) | ||
| .from(submission) | ||
| .innerJoin(executionResult, eq(executionResult.submissionId, submission.id)) | ||
| .where(and( | ||
| eq(submission.userId, userId), | ||
| eq(submission.mode, 'SUBMIT'), | ||
| eq(executionResult.verdict, 'ACCEPTED') | ||
| )); | ||
|
|
||
| // Group accepted by difficulty | ||
| const acceptedWithDiff = await db | ||
| .selectDistinct({ problemId: submission.problemId, difficulty: problem.difficulty }) | ||
| .from(submission) | ||
| .innerJoin(executionResult, eq(executionResult.submissionId, submission.id)) | ||
| .innerJoin(problem, eq(problem.id, submission.problemId)) | ||
| .where(and( | ||
| eq(submission.userId, userId), | ||
| eq(submission.mode, 'SUBMIT'), | ||
| eq(executionResult.verdict, 'ACCEPTED') | ||
| )); | ||
|
|
||
| const easyCount = acceptedWithDiff.filter(r => r.difficulty === 'EASY').length; | ||
| const mediumCount = acceptedWithDiff.filter(r => r.difficulty === 'MEDIUM').length; | ||
| const hardCount = acceptedWithDiff.filter(r => r.difficulty === 'HARD').length; |
Comment on lines
+276
to
+281
| return { | ||
| totalSubmissions: 0, | ||
| totalSolved: 0, | ||
| solvedByDifficulty: { easy: 0, medium: 0, hard: 0 }, | ||
| recentSubmissions: [], | ||
| }; |
Comment on lines
+58
to
+61
| success: true, | ||
| data: response, | ||
| }); | ||
| }); |
Comment on lines
+2
to
+8
| import { Link, useNavigate } from "react-router-dom"; | ||
| import { useAuth } from "@/hooks/AuthContext"; | ||
| import { getUserDashboardStats } from "@/api/api"; | ||
| import { | ||
| Trophy, Code2, CheckCircle2, XCircle, Clock, Cpu, | ||
| ChevronRight, BarChart3, User, Zap, BookOpen, | ||
| MessageSquare, Target, TrendingUp, Calendar, Star |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Clicking on dashboard leads to a user dashboard page with rich analytics for users to see their submissions and problem count.